#!/bin/sh
echo "请输入需要检测的工程路径"
read path
if [ ${#path} = 0 ]
    then
        echo "请在.sh文件后面添加路径"
        exit
    fi
cd $path
echo "当前路径为`pwd`" 
#搜索目录下面的.a文件
for i in `find . -name *.a`; do
    # echo $i
    i_=${i##*/}
    # echo $i_
    i_=${i_%.a}
    # echo $i_
    nm -n $i >> "$i_.txt"
    grep 'dlopen' "$i_.txt" >/dev/null 2>&1 || grep 'dlsym' "$i_.txt" >/dev/null 2>&1 || grep 'respondsToSelector' "$i_.txt" >/dev/null 2>&1 || grep 'performSelector' "$i_.txt" >/dev/null 2>&1
    if [[ $? == 0 ]]; then
        echo "$i_ 中有dlopen dlsym respondsToSelector performSelector"
    fi
    rm $i_.txt
done
#搜索目录下面的framework
for i in `find *.framework/ */*.framework/  -size +100k`; do
    # echo $i
    i_=${i##*/}
    # echo $i_
    nm -n $i >> "$i_.txt"
    grep 'dlopen' "$i_.txt" >/dev/null 2>&1 || grep 'dlsym' "$i_.txt" >/dev/null 2>&1 || grep 'respondsToSelector' "$i_.txt" >/dev/null 2>&1 || grep 'performSelector' "$i_.txt" >/dev/null 2>&1
    if [[ $? == 0 ]]; then
        echo "$i_ 中有dlopen dlsym respondsToSelector performSelector"
    fi
    rm $i_.txt
done